﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using System.Text;
using CoreEx.Common.Data;
using CoreEx.Database.Metadata;
using CoreEx.Database.Query;

namespace CoreEx.Database.Linq
{
    /// <summary>
    /// Represents a per type/property <see cref="IExpression"/>. 
    /// </summary>
    public interface ITranslateResult_old
    {
        /// <summary>
        /// Gets or sets the <see cref="MemberInfo"/> instance that describes the projected type.
        /// </summary>
        Type ProjectedType { get; set; }

        /// <summary>
        /// Gets the <see cref="IExpression"/> instance that has been generated to populate the projected type.
        /// </summary>
        IExpression DbExpression { get; set; }

        /// <summary>
        /// Gets a list of <see cref="ITranslateResult"/> instances that represents the translated 
        /// query to populate a member belonging to the projected <see cref="Type"/>.
        /// </summary>
        IDictionary<MemberInfo, ITranslateResult_old> MemberResults { get; }

        /// <summary>
        /// Gets or sets the <see cref="Expression"/> instance that represents the source of the translation
        /// </summary>
        Expression Expression { get; set; }

        /// <summary>
        /// Gets or sets the root <see cref="Type"/> of the query.
        /// </summary>
        Type RootType { get; set; }

        /// <summary>
        /// Gets or sets the alias that is used to identify the <see cref="RootType"/>.
        /// </summary>
        int RootAlias { get; set; }


        /// <summary>
        /// Gets or sets the current alias used during translation of the query 
        /// </summary>
        int CurrentAlias { get; set; }

        /// <summary>
        /// Gets or sets the <see cref="TableInfo"/> instance that corresponds to the <see cref="RootType"/>.
        /// </summary>
        TableInfo TableInfo { get; set; }


        /// <summary>
        /// Gets or sets the parent <see cref="ITranslateResult"/>. 
        /// </summary>
        ITranslateResult_old ParentTranslateResult { get; set; }


        /// <summary>
        /// Gets or sets a <see cref="bool"/> value that indicates if this translation represents a sub query.
        /// </summary>
        bool IsSubQuery { get; set; }


        /// <summary>
        /// Gets or sets an <see cref="IList{T}"/> that contains all the expressions representing additional relations to be loaded.
        /// </summary>
        IList<Expression> LoadExpressions { get; set; }

        /// <summary>
        /// Gets or sets the <see cref="ITable"/> instance that contains the result of the database query;
        /// </summary>
        ITable Table { get; set;}

        /// <summary>
        /// Gets or sets the result of the database represented as custom objects.
        /// </summary>
        IList Result { get; set; }

        /// <summary>
        /// Gets or sets the <see cref="ITypeMappingInfo"/> instance that corresponds to the <see cref="RootType"/>.
        /// </summary>
        ITypeMappingInfo TypeMappingInfo { get; set; }


        /// <summary>
        /// Gets a list of <see cref="IProjectionTarget"/> instances. 
        /// </summary>
        IDictionary<MemberInfo, IProjectionTarget_old> ProjectionTargets { get; }

        /// <summary>
         /// Gets or sets the <see cref="IRelationLoadTarget"/> instance that was used to load this <see cref="ITranslateResult"/>.
        /// </summary>
        IRelationLoadTarget RelationLoadTarget { get; set; }

    }
}